package com.edu.atguigu.spring5.aopanno;/*
@author joker
@create 2022-03-23 21:22
Spring_atguigu02
*/

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Aspect
@Order(1)
public class UserProxy {
    /**相同切入点抽取*/
    @Pointcut(value = "execution(* com.edu.atguigu.spring5.aopanno.User.add(..))")
    public void pointdemo(){

    }

    /**前置通知*/
    @Before(value = "pointdemo()")

    public void before(){
        System.out.println("before...");
    }
    /**后置通知*/
    @After(value = "pointdemo()")
    public void after(){
        System.out.println("after...");
    }
    /**环绕通知*/
    @Around(value = "pointdemo()")
    public void around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        System.out.println("环绕之前...");
        //被增强的方法执行
        proceedingJoinPoint.proceed();
        System.out.println("环绕之后...");
    }
    /**后置退出通知*/
    @AfterReturning(value = "pointdemo()")
    public void aferreturning(){
        System.out.println("afterReturning...");
    }
    /**后置异常通知*/
    @AfterThrowing(value = "pointdemo()")
    public void afterthrowing(){
        System.out.println("AfterThrowing...");
    }
}
